package com.suxin.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @Classname HttpChannelHandlerAdapter
 * @Description [ TODO ]
 * @Author Tang
 * @Date 2021/1/3 20:19
 * @Created by ASUS
 */
public class HttpChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {

        ChannelPipeline pipeline = ch.pipeline();

        // 加入一个netty提供的 HttpServerCodec 用来处理http的编-解码器
        pipeline.addLast("MyHttpServerCodec", new HttpServerCodec());

        // 自定义的 handler
        pipeline.addLast("myHttpServerHandler", new MyHttpServerHandler());

    }
}